// TOWN SCRIPT
//    Town 0: Greenleaf

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

int ticks1;

body;

beginstate INIT_STATE;
// Called upon entering

	//Vat stuff
	if(get_flag(0,12) == 1) { //If told Mayor, and not fixed
		set_flag(0,7,2);
		set_terrain(29,18,249);
		set_flag(0,12,2);
	}

	//Names
	set_name(8,"Sal");
	set_char_dialogue_pic(8,512,0);
	set_name(9,"Liam");
	set_char_dialogue_pic(9,1961,0);
	set_name(10,"Liam");
	set_char_dialogue_pic(10,1961,0);
	set_name(11,"Kathleen");
	set_char_dialogue_pic(11,513,0);
	set_name(12,"Captain Sterling");
	set_char_dialogue_pic(12,1947,0);
	set_name(14,"Rose");
	set_char_dialogue_pic(14,524,0);
	set_name(15,"Emily");
	set_name(16,"Emily");
	set_name(17,"Kurt");
	set_char_dialogue_pic(17,1945,0);
	set_name(20,"Eric");
	set_char_dialogue_pic(20,1949,0);
	set_character_pose(24,14); //Make guard lay
	set_character_pose(27,14); //Make archer lay
	set_name(29,"Townswoman");
	set_character_pose(27,14);
	set_name(30,"Townswoman");
	set_name(31,"Townswoman");
	set_name(32,"Soldier");
	set_name(35,"Preston"); //a.k.a "the dreamboat", "buddy holly mk2". Oh, and he plays bass with the best band in plymouth - the Prima Doners. :P (P.S, if you ever see this mister, you owe me money. lots of money. (: )
	set_char_dialogue_pic(35,525,0); //Just until I get a decent picture of Mr Holly.
	set_name(36,"Mayor Stone");
	set_char_dialogue_pic(36,1946,0);
	
	//Night time stuff
if(get_flag(250,0) == 1) {
	erase_char(8); 		//Kill Sal
	erase_char(9); 		//Kill Liam
	erase_char(14); 	//Kill Rose
	erase_char(15); 	//Kill Emily
	erase_char(17); 	//Kill Kurt so he can appear upstairs
	erase_char(22);		//Kill archer so can go to temple
	erase_char(23);		//Kill southern guard
	spawn_creature(24); //make soldier appear lying down
	erase_char(25); 	//Kill night guard (inn)
	erase_char(27);		//Kill sleeping night archer in barracks
	erase_char(30);		//kill wandering good witch
	activate_hidden_group(1); //Make night people appear
	//Set names
	set_name(10,"Liam");
	set_char_dialogue_pic(10,1961,0);
	set_name(16,"Emily");
	set_character_pose(24,14); //Make guard lay
	set_name(29,"Townswoman");
	set_name(31,"Townswoman");
	set_name(32,"Soldier");
	//Set flags
}
//Day stuff
if(get_flag(250,0) == 0) {
	spawn_creature(8); 	//Make Sal go to stall
	spawn_creature(9); 	//Make Liam go to stall
	erase_char(10); 	//Kill pub Liam
	spawn_creature(14); //Make rose go to shop
	spawn_creature(15); //Bring Em back
	erase_char(16); 	//Kill night Emily
	spawn_creature(17); //Make Kurt Appear
	erase_char(21); 	//Kill temple Archer
	spawn_creature(22); //Make temple archer go back on patrol.
	spawn_creature(23); //Make guard reappear to s
	erase_char(24);		//Kill sleeping guard
	spawn_creature(25);	//Make night guard appear in inn
	erase_char(26);		//Kill night guard so he can go to inn.
	spawn_creature(27); //Make night archer sleep in barracks
	erase_char(28); 	//Kill night archer on streets
	erase_char(29);		//Kill good witch in inn
	spawn_creature(30); //make good witch walk outside
	//Set names
	set_name(8,"Sal");
	set_char_dialogue_pic(8,512,0);
	set_name(9,"Liam");
	set_char_dialogue_pic(9,1961,0);
	set_name(14,"Rose");
	set_char_dialogue_pic(14,524,0);
	set_name(15,"Emily");
	set_name(17,"Kurt");
	set_char_dialogue_pic(17,1945,0);
	set_character_pose(27,14);
	set_name(30,"Townswoman");
	set_name(31,"Townswoman");
	set_name(32,"Soldier");
	//Set flags	
	set_flag(250,4,0); //Make nIght time change happen
}

//initial entry message
if(get_flag(0,29) == 0) {
	reset_dialog();
	add_dialog_str(0,"You enter the town of Greenleaf for the very first time. It has been built in the centre of a forest, with strong stone buildings standing between tall birch trees.",0);
	if(get_flag(250,0) == 0) {
		add_dialog_str(1,"At the moment, the sun is shining down strongly, and the sky is nearly cloudless. The town looks busy - people are running to-and-fro on errands, visiting friends, and so on.",0);
	} else {
		add_dialog_str(1,"You look up, and see the moon shining fiercely, a multitude of stars scattered around it. Everything seems very peaceful, although you can just about make out snatches of conversation to the south and the east.",0);
	}
	add_dialog_str(2,"You look around for the mayor's office, which is where you are supposed to find out the details of your mission, and notice that Greenleaf, along with every other square-inch of the Valley, is covered in flowers.",0);
	add_dialog_str(3,"You smile and move on - maybe if you wrap up your mission fairly quickly, you can spend a few days enjoying this place properly.",0);
	run_dialog(1);
	set_flag(0,29,1);
}

//message after t2
if((get_flag(2,3) == 1) && get_flag(0,27) == 0) {
	message_dialog("Roxy is waiting for you when you emerge from the trapdoor. She forces a smile. _Right, we need to see Mayor Stone. And remember, don't breathe a word of this to anybody._","You nod, and go to Mayor Stone's office together.");
	teleport_party(14,11,1);
	activate_hidden_group(3);
	block_entry(1);
	set_flag(0,27,1);
	force_instant_terrain_redraw();

	pause(2 * get_flag(250,5));
		
	message_dialog("You and Roxy tell Mayor Stone what just happened. He grows paler with each word. _Well. This is..._ he starts. He looks at both you and Roxy keenly.","_You'll have to go to his Tower, and find Laurina._");
	message_dialog("There is a long pause. Eventually, Roxy nods. _Okay. You guys go on ahead. I'm going to talk to Har...Mayor Stone._ They both fall silent and wait for you to leave.","");
	
}

if(get_flag(250,6) != 0) {
	force_instant_terrain_redraw();
	message_dialog("As you arrive in Greenleaf, somebody sees that you have Laurina with you. Immediately, the whole town rushes to see you.","Mayor Stone runs up to you, and embraces each of you, and then turns to his daughter.");
	message_dialog("_Laurina, are you okay, what happened?_ he says to her.","The whole town listens on as Laurina tells her tale...");
	
	reset_dialog();
	add_dialog_str(0,"_Me and Tovas are in love. We ran away together. I know what he is, and I don't care. I know he killed people, and I can live with that. But he couldn't.",0);
	add_dialog_str(1,"She starts to weep. _He has left me, until I am old enough to choose between living without him, or dying to be with him. My choice has already been made, but he won't do it until I come of age._",0);
	add_dialog_str(2,"She turns to Stone. _And Father, you won't change my mind. I will be with him._ And with that, she walks off by herself. Everybody looks around confused. What just happened here?",0);
	add_dialog_str(3,"After a moment, the people turn to you. They look at you hopefully, and ask about their other friends. You have to say that you couldn't find any trace of either of them, at all. Eventually, after a few more questions, the crowd disperses.",0);
	add_dialog_str(4,"You look around. You have a feeling, you haven't heard the last of Tovas, or Laurina. Eventually, you leave town, and retrace your steps, looking for Tovas or at least some clue of his next destination.",0);
	run_dialog(1);
	
	message_dialog("But you never find him. You leave the Valley, but you never forget the events of the last few days... It's almost as if these things have been building up for years and years, and you are just seeing the final few stages of them...","The End.");
	end_scenario(1);
}	

//Crime stuff
set_crime_tolerance(1);

break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// Called every turn.

//Night time stuff
if(get_flag(250,0) == 1) { //if night AND not changed
	if(get_flag(250,4) == 0) {
	erase_char(8); 		//Kill Sal
	erase_char(9); 		//Kill Liam
	erase_char(14); 	//Kill Rose
	erase_char(15); 	//Kill Emily
	erase_char(17); 	//Kill Kurt so he can appear upstairs
	erase_char(22);		//Kill archer so can go to temple
	erase_char(23);		//Kill southern guard
	spawn_creature(24); //make soldier appear lying down
	erase_char(25); 	//Kill night guard (inn)
	erase_char(27);		//Kill sleeping night archer in barracks
	erase_char(30);		//kill wandering good witch
	activate_hidden_group(1); //Make night people appear
	//Set names
	set_name(10,"Liam");
	set_char_dialogue_pic(10,1961,0);
	set_name(16,"Emily");
	set_character_pose(24,14); //Make guard lay
	set_name(29,"Townswoman");
	set_name(31,"Townswoman");
	set_name(32,"Soldier");
	//Set flags
	set_flag(250,4,1); //stop changing every turn, since this causes slow down
}	
}
//Day stuff
if(get_flag(250,0) == 0) { //if day AND not changed
	if(get_flag(250,3) == 0) {
	spawn_creature(8); 	//Make Sal go to stall
	spawn_creature(9); 	//Make Liam go to stall
	erase_char(10); 	//Kill pub Liam
	spawn_creature(14); //Make rose go to shop
	spawn_creature(15); //Bring Em back
	erase_char(16); 	//Kill night Emily
	spawn_creature(17); //Make Kurt Appear
	erase_char(21); 	//Kill temple Archer
	spawn_creature(22); //Make temple archer go back on patrol.
	spawn_creature(23); //Make guard reappear to s
	erase_char(24);		//Kill sleeping guard
	spawn_creature(25);	//Make night guard appear in inn
	erase_char(26);		//Kill night guard so he can go to inn.
	spawn_creature(27); //Make night archer sleep in barracks
	erase_char(28); 	//Kill night archer on streets
	erase_char(29);		//Kill good witch in inn
	spawn_creature(30); //make good witch walk outside
	//Set names
	set_name(8,"Sal");
	set_char_dialogue_pic(8,512,0);
	set_name(9,"Liam");
	set_char_dialogue_pic(9,1961,0);
	set_name(14,"Rose");
	set_char_dialogue_pic(14,524,0);
	set_name(15,"Emily");
	set_name(17,"Kurt");
	set_char_dialogue_pic(17,1945,0);
	set_character_pose(27,14);
	set_name(30,"Townswoman");
	set_name(31,"Townswoman");
	set_name(32,"Soldier");
	//Set flags	
	set_flag(250,3,1); //Make nIght time change happen
	}
}

//Message as night falls
if((get_current_tick() % 5000) == 3750) {
		message_dialog("As night descends, everything in town changes. Almost immediately, everything grows quieter. People run off the streets and inside. You are left almost alone...","Only a smattering of on-duty soldiers, and the haunting sound of music remind you that this place is populated.");
}

//message as day dawns
if((get_current_tick() % 5000) == 250) {
	message_dialog("As the sun rises above the horizon, Greenleaf bursts into life. Where before they had been quiet, the streets are now alive with sound. You watch as people leave their houses, and step into the sunlight.","");
}

//if party are naughty punish them
if (get_crime_level() >= 1) {
	message_dialog("A swarm of soldiers and angry townspeople rush you, take you by force, arrest you, and take you to the Captain here in Greenleaf.","She reads out a list of your crimes, and decides the best course of action is to expel you from the Valley. You return home shame-faced.");
		end_scenario(0);
	}

//text bubbles (pronounced "boo-bay-lays")



if(get_ran(1,0,100) < 10)
		text_bubble_on_char(7,"Get lost.");	

if(char_ok(8) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(8,"Fancy anything?");
if(char_ok(8) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(8,"*Cough*");
		
if(char_ok(9) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(9,"Come one, come all!");
if(char_ok(9) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(9,"I wish business would pick up.");	
		
if(char_ok(10) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(10,"Come find me tomorrow");
if(char_ok(10) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(10,"Ah...");					
		
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(11,"*strum strum*");
		
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(12,"*Sigh*");
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(12,"Did you want something?");
		
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(14,"Can I help you?");
		
if(char_ok(15) && (get_ran(1,0,100) < 30))
		text_bubble_on_char(15,"Ste-ven!");
if(char_ok(15) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(15,"Oh I'll never find him!");
		
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(16,"Our Father...");
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(16,"Who art in Heaven...");		
		
if(char_ok(17) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(17,"*tink tink*");	
if(char_ok(17) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(17,"Business is great!");
		
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(18,"*whisper*");	

if(get_ran(1,0,100) > 93)
		text_bubble_on_char(19,"*whisper*");	
		
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(20,"All are welcome.");	
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(20,"It is good to see you.");		
		
if(char_ok(9) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(24,"Zzzz");
		
if(char_ok(9) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(27,"Zzzz");
		
if(char_ok(29) && (get_ran(1,0,100) < 7))
		text_bubble_on_char(29,"I do hope you find her.");
		
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(33,"Supply should equal demand...");				
	
if(get_ran(1,0,100) < 5)
		text_bubble_on_char(34,"*meow*");			
			
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(35,"Can I help you?");		
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(35,"Drinks half price!");				
		
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(36,"Oh please find her!");
if(get_ran(1,0,100) < 7)
		text_bubble_on_char(36,"Was there something else?");	
					
break;

//Commander's Shelves
beginstate 10;
	if(get_flag(0,1) == 0) {
		message_dialog("These shelves are crammed to bursting. Scraps of yellowing paper are tucked inside stacks of scrolls, which themselves are poking out of thick, dusty, leather-bound books.","Not wanting to upset the very questionable filing system (and conscious that the slightest knock might bring the whole lot down upon you), you leave them be.");
		set_flag(0,1,1);
	} else {
		print_str("You browse these (unstable) shelves, but find nothing");
	}
break;

//Altar in temple
beginstate 11;
	if(get_flag(0,2) == 0) {
		message_dialog("You approach this rather plain altar. It is basically a huge slab of rock that has been smoothed down completely, and has then had holy words engraved upon it. The whole thing is rather fancifully decorated with a lilac cloth.","Standing near it, you feel more relaxed, more alive, like you *belong*. It must have an enchantment upon it. Alas, it is not strong enough to do anything truly beneficial for you.");
		set_flag(0,2,1);
	} else {
		message_dialog("You stand near the altar again. Once more, it relaxes you, and you soon feel completely calm.","");
	}
break;
	
//Temple Greeting
beginstate 12;
	if(get_flag(0,3) == 0) {
		message_dialog("You enter Greenleaf's small shrine for the first time. It is fairly large for the size of the community it serves, but doesn't suffer from the impersonal feeling that many big churches do.","There are a couple of people in here at the moment, all praying. As you look around, you spot the church leader. He smiles, and motions for you to join him.");
		set_flag(0,3,1);
	}
break;

//Painting in Temple
beginstate 13;
	if(get_flag(0,6) == 0) {
		message_dialog("You stand and admire this painting for a little while. It is beautiful beyond description. Somebody has painstakingly recreated the Valley in amazing detail - even the individual petals on the lilacs are present.","You look for an artist's signature, but there isn't one present. Maybe somebody in town will know who painted it.");
		set_flag(0,6,1);
	}
break;
		
//Tovas's Door/Sign 
beginstate 14;
	small_draw_pic_dialog(511,"Somebody has scrawled a message here:"); 
	set_flag(0,9,1);
break;

//Trapdoor to T2
beginstate 15;
	if(is_combat() == 1) {
		block_entry(1);
		print_str_color("You can't climb down the trapdoor in combat mode.",3);
		end();
		}
		
	reset_dialog();
	add_dialog_str(0,"You find a trapdoor in the far corner. Lifting the door, you peer down. You can't make much out - you'll have to go down to have a proper look. Do you wish to climb down?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	if(run_dialog(1) == 1) {
		print_str_color("You climb downstairs",3);
		move_to_new_town (2,27,26);
	} else {
		block_entry(1);
	}
break;

//Vat in Tovas's room
beginstate 16;
	if(get_flag(0,7) == 0) {
		if(get_skill_total(14) < 10) {
			message_dialog("This cauldron is full of a viscous, noxious goo. Just being near it makes you feel slightly ill. This shouldn't be allowed to be left here - it might spill or burn its way outside.","Unfortunately, there is nothing you can do apart from telling somebody about it...");
			set_flag(0,7,1);
			end();
		}
		if(get_skill_total(14) > 9) {
			message_dialog("This cauldron is full of a viscous, noxious goo. Just being near it makes you feel slightly ill. This shouldn't be allowed to be left here - it might spill or burn its way outside.","Fortunately, you know enough about alchemy to neutralise the goo...");
			message_dialog("Grabbing the nearby sprig of mandrake, you throw it in, and hope that it works. It does. After a minute or so, the fumes subside, and the colour changes.","It will be much safer now.");
			set_flag(0,7,2);
			set_terrain(29,18,249);
			award_party_xp(20,15);
			end();
		}
	} 
	if(get_flag(0,7) == 2) {
		message_dialog("You return to the vat. It is now completely safe.","");
	}
break;
	
//Tovas's Room Greeting
beginstate 17; 
	if((get_flag(0,8) == 0) && (get_flag(0,9) == 1) && (get_flag(0,10) == 0))	{
		message_dialog("You enter this small shop, mindful that the sign outside said it was closed. Looking around, you see that everything is covered in dust, and random junk is thrown everywhere.","Looking closer, you see boot prints in the dust - it appears you aren't the only person poking about the Valley.");
		set_flag(0,8,1);
	}
	if((get_flag(0,8) == 0) && (get_flag(0,9) == 1) && (get_flag(0,10) == 1))	{
		message_dialog("You enter this small shop, mindful that the sign outside said it was closed. Looking around, you see that everything is covered in dust, and random junk is thrown everywhere.","Looking closer, you see boot prints in the dust - it appears Roxy has been here ahead of you.");
		set_flag(0,8,1);
	}
	if((get_flag(0,8) == 0) && (get_flag(0,9) == 0) && (get_flag(0,10) == 0))	{ 
		message_dialog("You enter this small shop, and immediately see that it has been abandoned. Looking around, you see that everything is covered in dust, and random junk is thrown everywhere.","Looking closer, you see boot prints in the dust - it appears you aren't the only person poking about the Valley.");
		set_flag(0,8,1);
	}
	if((get_flag(0,8) == 0) && (get_flag(0,9) == 0) && (get_flag(0,10) == 1))	{ 
		message_dialog("You enter this small shop, and immediately see that it has been abandoned. Looking around, you see that everything is covered in dust, and random junk is thrown everywhere.","Looking closer, you see boot prints in the dust - it appears Roxy has been here ahead of you.");
		set_flag(0,8,1); 
	}
break;

//Poisonous Air
beginstate 18; 
	if((get_flag(0,11) == 0) && (get_flag(0,7) == 0)) { //Not triggered or fixed
		message_dialog("As you approach the building in front of you, you start to feel a little woozy. Your head starts hurting, and it becomes slightly harder to breathe.","There must be something noxious in the air. You wonder what it is...");
		set_flag(0,11,1);
	} 
break;
	
//Captain's Room
beginstate 19;
	if((get_flag(0,21) == 0) && (get_flag(8,7) == 0)) {
		reset_dialog();
		add_dialog_str(0,"You enter this small room and look about. Several bookcases line the northern wall, crammed with all manner of paper. A desk is in the far corner, with piles of paperwork stacked upon it.",0);
		add_dialog_str(1,"And, over by the window, the commanding officer for the troops stationed here is gazing out of the window. She turns around as you approach, and smiles.",0);
		add_dialog_str(2,"_Come on in. You must be Stone's adventurers. Come and talk to me - I may be able to help you._",0);
		run_dialog(1);
		set_flag(0,21,1);
		set_flag(8,7,1);
	}
break;

//Sals House
beginstate 20;
	if(is_combat() == 1) {
		block_entry(1);
		print_str_color("You can't climb the ladder in combat mode.",3);
		end();
		}
		
	reset_dialog();
	add_dialog_str(0,"This ladder leads upstairs. Do you wish to climb up?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	if(run_dialog(1) == 1) {
		print_str_color("You climb upstairs",3);
		move_to_new_town (1,31,31);
	} else {
		block_entry(1);
	}
break;
		
//Big Sw House	
beginstate 21;
	if(is_combat() == 1) {
		block_entry(1);
		print_str_color("You can't climb the ladder in combat mode.",3);
		end();
		}
		
	reset_dialog();
	add_dialog_str(0,"This ladder leads upstairs. Do you wish to climb up?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	if(run_dialog(1) == 1) {
		print_str_color("You climb upstairs",3);
		move_to_new_town (1,40,33);
	} else {
		block_entry(1);
	}
break;

beginstate 22;
	if(is_combat() == 1) {
		block_entry(1);
		print_str_color("You can't climb the ladder in combat mode.",3);
		end();
		}
		
	reset_dialog();
	add_dialog_str(0,"This ladder leads upstairs. Do you wish to climb up?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	if(run_dialog(1) == 1) {
		print_str_color("You climb upstairs",3);
		move_to_new_town (1,27,38);
	} else {
		block_entry(1);
	}
break;

//Inn ladder
beginstate 23;
	if(is_combat() == 1) {
	block_entry(1);
	print_str_color("You can't climb the ladder in combat mode.",3);
	end();
	}
		
	reset_dialog();
	add_dialog_str(0,"This ladder leads upstairs. Do you wish to climb up?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	if(run_dialog(1) == 1) {
		print_str_color("You climb upstairs",3);
		move_to_new_town (1,9,38);
	} else {
		block_entry(1);
	}
break;

//Smith Ladder
beginstate 24;
	if(is_combat() == 1) {
	block_entry(1);
	print_str_color("You can't climb the ladder in combat mode.",3);
	end();
	}
		
	reset_dialog();
	add_dialog_str(0,"This ladder leads upstairs. Do you wish to climb up?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	if(run_dialog(1) == 1) {
		print_str_color("You climb upstairs",3);
		move_to_new_town (1,7,17);
	} else {
		block_entry(1);
	}
break;

//Rose shelves
beginstate 25;
	message_dialog("You look over these shelves, but find nothing that seems either interesting or useful. You move on.","");
break;

//Southern House ladder
beginstate 26;
	if(is_combat() == 1) {
	block_entry(1);
	print_str_color("You can't climb the ladder in combat mode.",3);
	end();
	}
		
	reset_dialog();
	add_dialog_str(0,"This ladder leads upstairs. Do you wish to climb up?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	if(run_dialog(1) == 1) {
		print_str_color("You climb upstairs",3);
		move_to_new_town (1,34,40);
	} else {
		block_entry(1);
	}
break;

//Abandoned House greeting
beginstate 27;		
	if(get_flag(0,28) == 0) {
		message_dialog("After entering this house, you look around. It looks like it hasn't been lived in for quite some time. You call out to whoever might be inside, but get no response.","Whoever lived here must have fled when the disappearances began happening. Or else was a victim of them.");
		set_flag(0,28,1);
	}
break;

//Inn greeting
beginstate 28;
	if(get_flag(8,0) == 0) {
		message_dialog("You enter the Blackfang Arms. It is a lot quieter then most pubs you've visited, but, given the situation in town, that's understandable.","The bar-man catches your eye as you look around and smiles at you, before waving you across to the bar.");
		set_flag(8,0,1);
	}
break;

//Barracks Ladder
beginstate 29;
	if(is_combat() == 1) {
	block_entry(1);
	print_str_color("You can't climb the ladder in combat mode.",3);
	end();
	}
		
	reset_dialog();
	add_dialog_str(0,"This ladder leads upstairs. Do you wish to climb up?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	if(run_dialog(1) == 1) {
		print_str_color("You climb upstairs",3);
		move_to_new_town (1,27,34);
	} else {
		block_entry(1);
	}
break;
	
//barracks greeting
beginstate 30;
	if(get_flag(8,3) == 0) {
		message_dialog("You enter Greenleaf's barracks. It is this small room that the dozen or so soldiers in the valley operate from. Looking around, you're surprised by how tidy everything is.","The commanding officer must run a very tight ship, which is comforting considering the recent events in town.");
		set_flag(8,3,1);
	}
break; 

//Rose's room greeting
beginstate 31;
	if((get_flag(8,4) == 0) && (get_flag(250,0) == 0)) {
		message_dialog("As you enter this little shop, you hear a tiny bell chime from above you. The shopkeeper looks up from a book she was reading before you arrived, and smiles wearily, before placing her book to one side.","");
		set_flag(8,4,1);
	}
	if((get_flag(8,4) == 0) && (get_flag(250,0) == 1)) {
		message_dialog("As you enter this little shop, you hear a tiny bell chime from above you.","");
		set_flag(8,4,1);
		}
break;

//door chime for roses shop
beginstate 32;
	play_sound(-15);
break;

//smithy greeting
beginstate 33;
	if(get_flag(8,5) == 0) {
		message_dialog("This odd-shaped building is Greenleaf's smithy. As you enter, you involuntarily take a step back - the place stinks of burning metal and dried sweat.","");
		set_flag(8,5,1);
	}
break;

//SE House shelves
beginstate 34;
	message_dialog("These shelves are crammed to bursting with various books. You glance over them and see titles like _Don Quixote_, _Yes Man_ and _Alice's Adventures In Wonderland._","Towards the bottom, though, are several untitled tomes. You pull one out, and flick through it. It's full of poetry, written in neat, looped handwriting. Unfortunately, there's nothing to be learnt from it. You put it back.");
break;

//Behind bar
beginstate 35;
	message_dialog("As you make your way 'round the bar, Preston spots what you're doing and yells at you.","_What are you doing?! Only I'm allowed back here! Get away!_");
	block_entry(1);
break;

//Mayors ladder
beginstate 36;
	if(is_combat() == 1) {
	block_entry(1);
	print_str_color("You can't climb the ladder in combat mode.",3);
	end();
	}
		
	reset_dialog();
	add_dialog_str(0,"This ladder leads upstairs. Do you wish to climb up?",0);
	add_dialog_choice(0,"Yes.");
	add_dialog_choice(1,"No.");
	if(run_dialog(1) == 1) {
		print_str_color("You climb upstairs",3);
		move_to_new_town (1,14,15);
	} else {
		block_entry(1);
	}
break;

//mayors shelves
beginstate 37;
	message_dialog("You browse through the many scrolls on this shelf, but they all seem to be standard Empire paperwork - there is nothing here to interest you, or anybody else for that matter.","");
break;

//mayors door - roxy leaves and goes to north exit when party approach
beginstate 38;
	if(get_flag(8,8) == 0) {
		message_dialog("As you approach this building, the door flies open, and someone walks out...","");
		activate_hidden_group(2);	
		flip_terrain(16,12);
		play_sound(-58);
		force_instant_terrain_redraw();
		
		relocate_character(13,16,12);
		force_instant_terrain_redraw();
		pause(2 * get_flag(250,5));
		
		set_character_facing(13,2);
		force_instant_terrain_redraw();
		pause(2 * get_flag(250,5));
		
		message_dialog("As she closes the door, somebody inside shouts out: _And Roxy? Thank you._","She closes the door gently, turns around, and begins moving down the path.");
		
		flip_terrain(16,12);
		play_sound(-59);
		pause(2 * get_flag(250,5));
		
		set_character_facing(13,6);
		force_instant_terrain_redraw();
		pause(2 * get_flag(250,5));
		
		relocate_character(13,17,12);
		force_instant_terrain_redraw();
		pause(2 * get_flag(250,5));
		
		relocate_character(13,18,12);
		force_instant_terrain_redraw();
		pause(2 * get_flag(250,5));
	
		message_dialog("The young lady realises you are watching her, smiles awkwardly, and then strides off to the north, and out of town. You wonder who she was...","");
		erase_char(13);
		
		set_flag(8,8,1);
	}
break;
		
//Mayor's door
beginstate 39;
	if((get_flag(8,9) == 0) &&	(get_flag(8,10) == 0)) {
		message_dialog("You step through this door, and into the Mayor's office. You don't get much chance to have a look around though - your attention is drawn to the far corner of the room.","There, sat behind a heavy wooden desk is a small man, presumably the mayor. He looks as if he has the world on his shoulders.");
	set_flag(8,9,1);
	}
break;  
	